<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta http-equiv="Cache-Control" content="no-siteapp">
  <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
  <meta name="renderer" content="webkit">

  
  <title>Android 10.0 锁屏壁纸 LockscreenWallpaper | 龙之叶的博客</title>

  <link rel="shortcut icon" href="/images/favicon.png">
  <link rel="alternate" href="/atom.xml" title="龙之叶的博客" type="application/atom+xml">
  <meta name="description" content="Android 10.0 锁屏壁纸 LockscreenWallpaper">
<meta property="og:type" content="article">
<meta property="og:title" content="Android 10.0 锁屏壁纸 LockscreenWallpaper">
<meta property="og:url" content="http://longzhiye.top/2024/01/01/2024-01-01/index.html">
<meta property="og:site_name" content="龙之叶的博客">
<meta property="og:description" content="Android 10.0 锁屏壁纸 LockscreenWallpaper">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="http://longzhiye.top/images/20240101/20240101001.png">
<meta property="article:published_time" content="2023-12-31T16:00:00.000Z">
<meta property="article:modified_time" content="2024-08-29T02:40:34.918Z">
<meta property="article:author" content="龙之叶">
<meta property="article:tag" content="Android">
<meta property="article:tag" content="Settings">
<meta property="article:tag" content="framework">
<meta property="article:tag" content="Launcher">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="http://longzhiye.top/images/20240101/20240101001.png">

  <meta name="keywords" content=",Android,Settings,framework,Launcher">
  <meta name="format-detection" content="telephone=no,email=no">
  <meta name="theme-color" content="#9C27B0">

  <meta name="mobile-web-app-capable" content="yes">
  <meta name="application-name" content="龙之叶的博客">
  <meta name="msapplication-starturl" content="http://longzhiye.top/2024/01/01/2024-01-01/">
  <meta name="msapplication-navbutton-color" content="#9C27B0">
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-title" content="龙之叶的博客">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">
  <link rel="apple-touch-icon" href="/images/favicon.png">

  
    <link rel="canonical" href="http://longzhiye.top/2024/01/01/2024-01-01/">
  

  
  

  
  
  

  
<link rel="stylesheet" href="/css/mdui.css">
<link rel="stylesheet" href="/css/style.css">

  
<link rel="stylesheet" href="/custom.css">

<meta name="generator" content="Hexo 5.4.2"></head>

<body class="mdui-appbar-with-toolbar mdui-theme-primary-indigo mdui-theme-accent-pink">
  <script>var a=localStorage.getItem("mdui-theme-layout-dark");if(a){document.getElementsByTagName("body")[0].className+=" mdui-theme-layout-dark"};</script>
  <script>if(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches){document.getElementsByTagName("body")[0].className+=" mdui-theme-layout-dark"};</script>
  <script>var a=localStorage.getItem("mdui-drawer-close");if(!a){document.getElementsByTagName("body")[0].className+=" mdui-drawer-body-left"};</script>
  <header id="header" class="mdui-appbar mdui-appbar-fixed mdui-appbar-scroll-hide mdui-appbar-inset">
  <div class="mdui-toolbar mdui-color-theme">
    <a href="javascript:;" class="mdui-btn mdui-btn-icon" mdui-drawer="{target: '#sidebar', swipe: true}"><i class="mdui-icon material-icons">menu</i></a>
    <a href="/" class="mdui-typo-headline">龙之叶的博客</a>
    <div class="mdui-toolbar-spacer"></div>
    <a href="javascript:;" class="mdui-btn mdui-btn-icon" mdui-dialog="{target: '#search'}" mdui-tooltip="{content: '搜索'}"><i class="mdui-icon material-icons">search</i></a>
	<!--
    <a href="/atom.xml" class="mdui-btn mdui-btn-icon" mdui-tooltip="{content: 'RSS'}"><i class="mdui-icon material-icons">rss_feed</i></a>
	-->
  </div>
</header>
<div class="mdui-dialog" id="search">
  
    <div class="search-form">
      <input type="search" class="search-form-input" placeholder="请输入关键字">
    </div>
    <div class="search-result" data-resource="/search.xml"></div>
  
</div>

  <aside id="sidebar" class="mdui-drawer mdui-drawer-full-height">
  <script>var a=localStorage.getItem("mdui-drawer-close");if(a){document.getElementById("sidebar").className+=" mdui-drawer-close"};</script>
  <div class="mdui-grid-tile">
    <img src="/images/banner.png" style="height: 160px;">
    <img src="/images/avatar.png" class="avatar-animation" style="position: absolute; top: 10%; left: 24px; width: 64px; height: 64px; border: 2px solid #fff; border-radius: 50%;background-color:#fff;">
    <div class="mdui-grid-tile-actions">
      <div class="mdui-grid-tile-text">
        <div class="mdui-grid-tile-title">龙之叶</div>
        <div class="mdui-grid-tile-subtitle"><i class="mdui-icon material-icons">art_track</i>生命不息，折腾不止</div>
      </div>
      
        <div class="mdui-grid-tile-buttons">
          <a href="mailto:longzhiye163@163.com" class="mdui-btn mdui-btn-icon" mdui-tooltip="{content: 'longzhiye163@163.com'}"><i class="mdui-icon material-icons">email</i></a>
        </div>
      
    </div>
  </div>

  <div class="mdui-list" mdui-collapse="{accordion: true}">
    <a href="/" class="mdui-list-item mdui-ripple">
      <i class="mdui-list-item-icon mdui-icon material-icons mdui-text-color-blue">home</i>
      <div class="mdui-list-item-content">主页</div>
    </a>
    <div class="mdui-collapse-item">
      <script>var a=localStorage.getItem("mdui-collapse-item-0");if(a){document.getElementsByClassName("mdui-collapse-item")[0].className+=" mdui-collapse-item-open"};</script>
      <div class="mdui-collapse-item-header mdui-list-item mdui-ripple">
        <i class="mdui-list-item-icon mdui-icon material-icons mdui-text-color-deep-orange">archive</i>
        <div class="mdui-list-item-content">归档</div>
        <i class="mdui-collapse-item-arrow mdui-icon material-icons">keyboard_arrow_down</i>
      </div>
      <div class="mdui-collapse-item-body mdui-list mdui-list-dense">
        
        <a class="mdui-ripple sidebar_archives-link" href="/archives/2025/07/">七月 2025<span class="mdui-ripple sidebar_archives-count">1</span></a><a class="mdui-ripple sidebar_archives-link" href="/archives/2025/06/">六月 2025<span class="mdui-ripple sidebar_archives-count">2</span></a><a class="mdui-ripple sidebar_archives-link" href="/archives/2025/03/">三月 2025<span class="mdui-ripple sidebar_archives-count">1</span></a><a class="mdui-ripple sidebar_archives-link" href="/archives/2025/02/">二月 2025<span class="mdui-ripple sidebar_archives-count">2</span></a><a class="mdui-ripple sidebar_archives-link" href="/archives/2025/01/">一月 2025<span class="mdui-ripple sidebar_archives-count">1</span></a><a class="mdui-ripple sidebar_archives-link" href="/archives/2024/10/">十月 2024<span class="mdui-ripple sidebar_archives-count">7</span></a><a class="mdui-ripple sidebar_archives-link" href="/archives/2024/09/">九月 2024<span class="mdui-ripple sidebar_archives-count">4</span></a><a class="mdui-ripple sidebar_archives-link" href="/archives/2024/08/">八月 2024<span class="mdui-ripple sidebar_archives-count">1</span></a><a class="mdui-ripple sidebar_archives-link" href="/archives/2024/03/">三月 2024<span class="mdui-ripple sidebar_archives-count">5</span></a><a class="mdui-ripple sidebar_archives-link" href="/archives/2024/02/">二月 2024<span class="mdui-ripple sidebar_archives-count">11</span></a><a class="mdui-ripple sidebar_archives-link" href="/archives/2024/01/">一月 2024<span class="mdui-ripple sidebar_archives-count">9</span></a><a class="mdui-ripple sidebar_archives-link" href="/archives/2023/12/">十二月 2023<span class="mdui-ripple sidebar_archives-count">10</span></a><a class="mdui-ripple sidebar_archives-link" href="/archives/2023/11/">十一月 2023<span class="mdui-ripple sidebar_archives-count">8</span></a><a class="mdui-ripple sidebar_archives-link" href="/archives/2023/10/">十月 2023<span class="mdui-ripple sidebar_archives-count">8</span></a><a class="mdui-ripple sidebar_archives-link" href="/archives/2023/09/">九月 2023<span class="mdui-ripple sidebar_archives-count">3</span></a><a class="mdui-ripple sidebar_archives-link" href="/archives/2023/08/">八月 2023<span class="mdui-ripple sidebar_archives-count">6</span></a><a class="mdui-ripple sidebar_archives-link" href="/archives/2023/06/">六月 2023<span class="mdui-ripple sidebar_archives-count">1</span></a><a class="mdui-ripple sidebar_archives-link" href="/archives/2023/05/">五月 2023<span class="mdui-ripple sidebar_archives-count">4</span></a><a class="mdui-ripple sidebar_archives-link" href="/archives/2023/04/">四月 2023<span class="mdui-ripple sidebar_archives-count">2</span></a><a class="mdui-ripple sidebar_archives-link" href="/archives/2023/03/">三月 2023<span class="mdui-ripple sidebar_archives-count">1</span></a><a class="mdui-ripple sidebar_archives-link" href="/archives/2023/02/">二月 2023<span class="mdui-ripple sidebar_archives-count">2</span></a><a class="mdui-ripple sidebar_archives-link" href="/archives/2022/09/">九月 2022<span class="mdui-ripple sidebar_archives-count">7</span></a><a class="mdui-ripple sidebar_archives-link" href="/archives/2022/08/">八月 2022<span class="mdui-ripple sidebar_archives-count">4</span></a><a class="mdui-ripple sidebar_archives-link" href="/archives/2017/04/">四月 2017<span class="mdui-ripple sidebar_archives-count">1</span></a><a class="mdui-ripple sidebar_archives-link" href="/archives/2017/03/">三月 2017<span class="mdui-ripple sidebar_archives-count">2</span></a><a class="mdui-ripple sidebar_archives-link" href="/archives/2017/02/">二月 2017<span class="mdui-ripple sidebar_archives-count">1</span></a><a class="mdui-ripple sidebar_archives-link" href="/archives/2017/01/">一月 2017<span class="mdui-ripple sidebar_archives-count">1</span></a><a class="mdui-ripple sidebar_archives-link" href="/archives/2016/12/">十二月 2016<span class="mdui-ripple sidebar_archives-count">1</span></a><a class="mdui-ripple sidebar_archives-link" href="/archives/2016/11/">十一月 2016<span class="mdui-ripple sidebar_archives-count">1</span></a><a class="mdui-ripple sidebar_archives-link" href="/archives/2016/10/">十月 2016<span class="mdui-ripple sidebar_archives-count">1</span></a><a class="mdui-ripple sidebar_archives-link" href="/archives/2016/08/">八月 2016<span class="mdui-ripple sidebar_archives-count">1</span></a>
        
      </div>
    </div>
    <div class="mdui-collapse-item">
      <script>var a=localStorage.getItem("mdui-collapse-item-1");if(a){document.getElementsByClassName("mdui-collapse-item")[1].className+=" mdui-collapse-item-open"};</script>
      <div class="mdui-collapse-item-header mdui-list-item mdui-ripple">
        <i class="mdui-list-item-icon mdui-icon material-icons mdui-text-color-green">class</i>
        <div class="mdui-list-item-content">分类</div>
        <i class="mdui-collapse-item-arrow mdui-icon material-icons">keyboard_arrow_down</i>
      </div>
      <div class="mdui-collapse-item-body mdui-list mdui-list-dense">
        
        <a class="mdui-ripple sidebar_archives-link" href="/categories/%E6%8A%80%E6%9C%AF/">技术<span class="mdui-ripple sidebar_archives-count">98</span></a><a class="mdui-ripple sidebar_archives-link" href="/categories/%E7%94%9F%E6%B4%BB/">生活<span class="mdui-ripple sidebar_archives-count">3</span></a><a class="mdui-ripple sidebar_archives-link" href="/categories/%E8%B5%84%E8%AE%AF/">资讯<span class="mdui-ripple sidebar_archives-count">4</span></a><a class="mdui-ripple sidebar_archives-link" href="/categories/%E9%80%9A%E7%9F%A5/">通知<span class="mdui-ripple sidebar_archives-count">4</span></a>
        
      </div>
    </div>
    <div class="mdui-collapse-item">
      <script>var a=localStorage.getItem("mdui-collapse-item-2");if(a){document.getElementsByClassName("mdui-collapse-item")[2].className+=" mdui-collapse-item-open"};</script>
      <div class="mdui-collapse-item-header mdui-list-item mdui-ripple">
        <i class="mdui-list-item-icon mdui-icon material-icons mdui-text-color-brown">bookmark</i>
        <div class="mdui-list-item-content">标签</div>
        <i class="mdui-collapse-item-arrow mdui-icon material-icons">keyboard_arrow_down</i>
      </div>
      <div class="mdui-collapse-item-body mdui-list mdui-list-dense">
        
        <a class="mdui-ripple sidebar_archives-link" href="/tags/ANR/" rel="tag">ANR<span class="mdui-ripple sidebar_archives-count">2</span></a><a class="mdui-ripple sidebar_archives-link" href="/tags/APP/" rel="tag">APP<span class="mdui-ripple sidebar_archives-count">1</span></a><a class="mdui-ripple sidebar_archives-link" href="/tags/Android/" rel="tag">Android<span class="mdui-ripple sidebar_archives-count">89</span></a><a class="mdui-ripple sidebar_archives-link" href="/tags/Android12/" rel="tag">Android12<span class="mdui-ripple sidebar_archives-count">3</span></a><a class="mdui-ripple sidebar_archives-link" href="/tags/Android13/" rel="tag">Android13<span class="mdui-ripple sidebar_archives-count">2</span></a><a class="mdui-ripple sidebar_archives-link" href="/tags/Android14/" rel="tag">Android14<span class="mdui-ripple sidebar_archives-count">1</span></a><a class="mdui-ripple sidebar_archives-link" href="/tags/AndroidStudio/" rel="tag">AndroidStudio<span class="mdui-ripple sidebar_archives-count">3</span></a><a class="mdui-ripple sidebar_archives-link" href="/tags/AutoDraw/" rel="tag">AutoDraw<span class="mdui-ripple sidebar_archives-count">1</span></a><a class="mdui-ripple sidebar_archives-link" href="/tags/Crash/" rel="tag">Crash<span class="mdui-ripple sidebar_archives-count">2</span></a><a class="mdui-ripple sidebar_archives-link" href="/tags/Foxmail/" rel="tag">Foxmail<span class="mdui-ripple sidebar_archives-count">1</span></a><a class="mdui-ripple sidebar_archives-link" href="/tags/Framework/" rel="tag">Framework<span class="mdui-ripple sidebar_archives-count">20</span></a><a class="mdui-ripple sidebar_archives-link" href="/tags/GPS%E8%BD%A8%E8%BF%B9%E5%9B%BE/" rel="tag">GPS轨迹图<span class="mdui-ripple sidebar_archives-count">1</span></a><a class="mdui-ripple sidebar_archives-link" href="/tags/Git/" rel="tag">Git<span class="mdui-ripple sidebar_archives-count">2</span></a><a class="mdui-ripple sidebar_archives-link" href="/tags/GitHub/" rel="tag">GitHub<span class="mdui-ripple sidebar_archives-count">1</span></a><a class="mdui-ripple sidebar_archives-link" href="/tags/Google/" rel="tag">Google<span class="mdui-ripple sidebar_archives-count">1</span></a><a class="mdui-ripple sidebar_archives-link" href="/tags/Hexo/" rel="tag">Hexo<span class="mdui-ripple sidebar_archives-count">1</span></a><a class="mdui-ripple sidebar_archives-link" href="/tags/Java/" rel="tag">Java<span class="mdui-ripple sidebar_archives-count">3</span></a><a class="mdui-ripple sidebar_archives-link" href="/tags/Kernel/" rel="tag">Kernel<span class="mdui-ripple sidebar_archives-count">4</span></a><a class="mdui-ripple sidebar_archives-link" href="/tags/Launcher/" rel="tag">Launcher<span class="mdui-ripple sidebar_archives-count">17</span></a><a class="mdui-ripple sidebar_archives-link" href="/tags/Lib/" rel="tag">Lib<span class="mdui-ripple sidebar_archives-count">1</span></a><a class="mdui-ripple sidebar_archives-link" href="/tags/Linux/" rel="tag">Linux<span class="mdui-ripple sidebar_archives-count">18</span></a><a class="mdui-ripple sidebar_archives-link" href="/tags/Markdown/" rel="tag">Markdown<span class="mdui-ripple sidebar_archives-count">1</span></a><a class="mdui-ripple sidebar_archives-link" href="/tags/Material-Design/" rel="tag">Material Design<span class="mdui-ripple sidebar_archives-count">1</span></a><a class="mdui-ripple sidebar_archives-link" href="/tags/OS-X/" rel="tag">OS X<span class="mdui-ripple sidebar_archives-count">1</span></a><a class="mdui-ripple sidebar_archives-link" href="/tags/OTA/" rel="tag">OTA<span class="mdui-ripple sidebar_archives-count">1</span></a><a class="mdui-ripple sidebar_archives-link" href="/tags/QuickTime/" rel="tag">QuickTime<span class="mdui-ripple sidebar_archives-count">1</span></a><a class="mdui-ripple sidebar_archives-link" href="/tags/SSH/" rel="tag">SSH<span class="mdui-ripple sidebar_archives-count">1</span></a><a class="mdui-ripple sidebar_archives-link" href="/tags/Settings/" rel="tag">Settings<span class="mdui-ripple sidebar_archives-count">6</span></a><a class="mdui-ripple sidebar_archives-link" href="/tags/SystemUI/" rel="tag">SystemUI<span class="mdui-ripple sidebar_archives-count">19</span></a><a class="mdui-ripple sidebar_archives-link" href="/tags/Ubuntu/" rel="tag">Ubuntu<span class="mdui-ripple sidebar_archives-count">7</span></a><a class="mdui-ripple sidebar_archives-link" href="/tags/WPS/" rel="tag">WPS<span class="mdui-ripple sidebar_archives-count">1</span></a><a class="mdui-ripple sidebar_archives-link" href="/tags/Wifi/" rel="tag">Wifi<span class="mdui-ripple sidebar_archives-count">1</span></a><a class="mdui-ripple sidebar_archives-link" href="/tags/WindTerm/" rel="tag">WindTerm<span class="mdui-ripple sidebar_archives-count">1</span></a><a class="mdui-ripple sidebar_archives-link" href="/tags/Windows/" rel="tag">Windows<span class="mdui-ripple sidebar_archives-count">1</span></a><a class="mdui-ripple sidebar_archives-link" href="/tags/androidmk/" rel="tag">androidmk<span class="mdui-ripple sidebar_archives-count">2</span></a><a class="mdui-ripple sidebar_archives-link" href="/tags/blog/" rel="tag">blog<span class="mdui-ripple sidebar_archives-count">1</span></a><a class="mdui-ripple sidebar_archives-link" href="/tags/build/" rel="tag">build<span class="mdui-ripple sidebar_archives-count">1</span></a><a class="mdui-ripple sidebar_archives-link" href="/tags/feel/" rel="tag">feel<span class="mdui-ripple sidebar_archives-count">2</span></a><a class="mdui-ripple sidebar_archives-link" href="/tags/framework/" rel="tag">framework<span class="mdui-ripple sidebar_archives-count">50</span></a><a class="mdui-ripple sidebar_archives-link" href="/tags/git/" rel="tag">git<span class="mdui-ripple sidebar_archives-count">1</span></a><a class="mdui-ripple sidebar_archives-link" href="/tags/inotify/" rel="tag">inotify<span class="mdui-ripple sidebar_archives-count">1</span></a><a class="mdui-ripple sidebar_archives-link" href="/tags/life/" rel="tag">life<span class="mdui-ripple sidebar_archives-count">2</span></a><a class="mdui-ripple sidebar_archives-link" href="/tags/ninja/" rel="tag">ninja<span class="mdui-ripple sidebar_archives-count">1</span></a><a class="mdui-ripple sidebar_archives-link" href="/tags/rsync/" rel="tag">rsync<span class="mdui-ripple sidebar_archives-count">2</span></a><a class="mdui-ripple sidebar_archives-link" href="/tags/standard/" rel="tag">standard<span class="mdui-ripple sidebar_archives-count">1</span></a><a class="mdui-ripple sidebar_archives-link" href="/tags/test/" rel="tag">test<span class="mdui-ripple sidebar_archives-count">1</span></a><a class="mdui-ripple sidebar_archives-link" href="/tags/%E4%BC%81%E4%B8%9A%E5%BE%AE%E4%BF%A1/" rel="tag">企业微信<span class="mdui-ripple sidebar_archives-count">1</span></a><a class="mdui-ripple sidebar_archives-link" href="/tags/%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F/" rel="tag">操作系统<span class="mdui-ripple sidebar_archives-count">1</span></a><a class="mdui-ripple sidebar_archives-link" href="/tags/%E6%B5%8B%E8%AF%95/" rel="tag">测试<span class="mdui-ripple sidebar_archives-count">1</span></a><a class="mdui-ripple sidebar_archives-link" href="/tags/%E6%BA%90%E7%A0%81/" rel="tag">源码<span class="mdui-ripple sidebar_archives-count">3</span></a><a class="mdui-ripple sidebar_archives-link" href="/tags/%E7%94%9F%E6%B4%BB%E6%84%9F%E6%82%9F/" rel="tag">生活感悟<span class="mdui-ripple sidebar_archives-count">1</span></a>
        
      </div>
    </div>
    <a href="/about" class="mdui-list-item mdui-ripple">
      <i class="mdui-list-item-icon mdui-icon material-icons mdui-text-color-purple">person</i>
      <div class="mdui-list-item-content">关于</div>
    </a>
  </div>

  <div class="mdui-divider"></div>

  <div class="mdui-list" mdui-collapse="{accordion: true}">
    
      <a href="/timeline" class="mdui-list-item mdui-ripple">时间轴</a>
    
    <div class="mdui-collapse-item">
      <script>var a=localStorage.getItem("mdui-collapse-item-3");if(a){document.getElementsByClassName("mdui-collapse-item")[3].className+=" mdui-collapse-item-open"};</script>
      <div class="mdui-collapse-item-header mdui-list-item mdui-ripple">
        <div class="mdui-list-item-content">友情链接</div>
        <i class="mdui-list-item-icon mdui-icon material-icons">link</i>
      </div>
      <div class="mdui-collapse-item-body mdui-list mdui-list-dense">
        
          <a href="http://www.niemingzhao.top" target="_blank" class="mdui-list-item mdui-p-l-2 mdui-text-color-theme-accent mdui-ripple" style="justify-content: center;">聂明照的博客</a>
        
        
      </div>
    </div>
  </div>
</aside>

  <main id="main" class="mdui-m-t-5 fadeIn animated">
  
<link rel="stylesheet" href="//cdn.bootcdn.net/ajax/libs/fancybox/3.5.7/jquery.fancybox.min.css">

  <style>#main article .mdui-card-content .center-block{display:block!important;margin-right:auto!important;margin-left:auto!important}</style>
  <style>#main article .mdui-card-content .text-center{text-align:center!important}</style>
  <article class="mdui-card mdui-m-b-5">
    <header class="mdui-card-media">
      <img src="/images/random/material-10.png" style="max-height: 240px;">
      <div class="mdui-card-media-covered">
        <div class="mdui-card-primary">
          <div class="mdui-card-primary-title">Android 10.0 锁屏壁纸 LockscreenWallpaper</div>
          <div class="mdui-card-primary-subtitle"><i class="iconfont">&#xe697;</i> 2024-01-01 / <i class="iconfont">&#xe601;</i> 龙之叶 &nbsp;&nbsp; <span id="busuanzi_container_page_pv" style="display: none;"><i class="iconfont">&#xe7fd;</i> <span id="busuanzi_value_page_pv"></span></span></div>
        </div>
      </div>
      <div class="mdui-card-menu">
        
          <button class="mdui-btn mdui-btn-icon mdui-text-color-white" mdui-menu="{target: '#qrcode', align: 'right'}"><i class="mdui-icon material-icons">devices</i></button>
          <ul class="mdui-menu" id="qrcode">
            
              <li class="mdui-menu-item"><a class="mdui-text-center mdui-ripple">发送到手机</a></li>
            
            <li class="mdui-menu-item" disabled>
              
                <img src="//qr.liantu.com/api.php?w=246&m=10&text=http://longzhiye.top/2024/01/01/2024-01-01/">
              
            </li>
          </ul>
        
        
          <button class="mdui-btn mdui-btn-icon mdui-text-color-white" mdui-menu="{target: '#share_menu', align: 'right'}"><i class="mdui-icon material-icons">share</i></button>
          <ul class="mdui-menu" id="share_menu">
            <li class="mdui-menu-item">
              <a href="https://service.weibo.com/share/share.php?appkey=&title=Android 10.0 锁屏壁纸 LockscreenWallpaper&url=http://longzhiye.top/2024/01/01/2024-01-01/&pic=http://longzhiye.top/images/favicon.png&searchPic=false&style=simple" target="_blank" class="mdui-ripple">分享到 Weibo</a>
            </li>
            <li class="mdui-menu-item">
              <a href="https://twitter.com/intent/tweet?text=Android 10.0 锁屏壁纸 LockscreenWallpaper&url=http://longzhiye.top/2024/01/01/2024-01-01/&via=龙之叶" target="_blank" class="mdui-ripple">分享到 Twitter</a>
            </li>
            <li class="mdui-menu-item">
              <a href="https://www.facebook.com/sharer/sharer.php?u=http://longzhiye.top/2024/01/01/2024-01-01/" target="_blank" class="mdui-ripple">分享到 Facebook</a>
            </li>
            <li class="mdui-menu-item">
              <a href="https://plus.google.com/share?url=http://longzhiye.top/2024/01/01/2024-01-01/" target="_blank" class="mdui-ripple">分享到 Google+</a>
            </li>
            <li class="mdui-menu-item">
              <a href="https://www.linkedin.com/shareArticle?mini=true&url=http://longzhiye.top/2024/01/01/2024-01-01/&title=Android 10.0 锁屏壁纸 LockscreenWallpaper" target="_blank" class="mdui-ripple">分享到 LinkedIn</a>
            </li>
            <li class="mdui-menu-item">
              <a href="https://connect.qq.com/widget/shareqq/index.html?site=龙之叶的博客&title=Android 10.0 锁屏壁纸 LockscreenWallpaper&pics=http://longzhiye.top/images/favicon.png&url=http://longzhiye.top/2024/01/01/2024-01-01/" target="_blank" class="mdui-ripple">分享到 QQ</a>
            </li>
            <li class="mdui-menu-item">
              <a href="https://telegram.me/share/url?url=http://longzhiye.top/2024/01/01/2024-01-01/&text=Android 10.0 锁屏壁纸 LockscreenWallpaper" target="_blank" class="mdui-ripple">分享到 Telegram</a>
            </li>
          </ul>
        
      </div>
    </header>
    <div class="mdui-card-content mdui-typo">
      <h3 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h3><h3 id="一、设置壁纸"><a href="#一、设置壁纸" class="headerlink" title="一、设置壁纸"></a>一、设置壁纸</h3><p>通过系统设置进行锁屏壁纸和桌面壁纸的设置。<br>Setting 部分的代码：<br><strong>packages/apps/WallpaperPicker2/src/com/android/wallpaper/module/DefaultWallpaperPersister.java</strong></p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line">    <span class="keyword">private</span> <span class="type">int</span> <span class="title function_">setStreamToWallpaperManagerCompat</span><span class="params">(InputStream inputStream, <span class="type">boolean</span> allowBackup,</span></span><br><span class="line"><span class="params">            <span class="type">int</span> whichWallpaper)</span> &#123;</span><br><span class="line">        <span class="keyword">try</span> &#123;</span><br><span class="line">            <span class="comment">// whichWallpaper  // 壁纸类型</span></span><br><span class="line">            <span class="keyword">return</span> mWallpaperManagerCompat.setStream(inputStream, <span class="literal">null</span>, allowBackup,</span><br><span class="line">                    whichWallpaper);</span><br><span class="line">        &#125; <span class="keyword">catch</span> (IOException e) &#123;</span><br><span class="line">            <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">  ...</span><br><span class="line"><span class="comment">//    int whichWallpaper;    // 壁纸类型</span></span><br><span class="line"><span class="comment">//    if (mDestination == DEST_HOME_SCREEN) &#123;    // 桌面壁纸</span></span><br><span class="line"><span class="comment">//        whichWallpaper = WallpaperManagerCompat.FLAG_SYSTEM;</span></span><br><span class="line"><span class="comment">//    &#125; else if (mDestination == DEST_LOCK_SCREEN) &#123;  // 锁屏壁纸</span></span><br><span class="line"><span class="comment">//        whichWallpaper = WallpaperManagerCompat.FLAG_LOCK;</span></span><br><span class="line"><span class="comment">//    &#125; else &#123; // DEST_BOTH    // 桌面壁纸 和 锁屏壁纸</span></span><br><span class="line"> <span class="comment">//       whichWallpaper = WallpaperManagerCompat.FLAG_SYSTEM</span></span><br><span class="line"><span class="comment">//                | WallpaperManagerCompat.FLAG_LOCK;</span></span><br><span class="line"><span class="comment">//    &#125;</span></span><br><span class="line">  ...</span><br></pre></td></tr></table></figure>
<p>mWallpaperManagerCompat 其实就是 WallpaperManagerCompatV16 的对象。<br><strong>packages/apps/WallpaperPicker2/src/com/android/wallpaper/compat/WallpaperManagerCompatV16.java</strong></p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">@Override</span></span><br><span class="line"><span class="keyword">public</span> <span class="type">int</span> <span class="title function_">setStream</span><span class="params">(InputStream data, Rect visibleCropHint, <span class="type">boolean</span> allowBackup,</span></span><br><span class="line"><span class="params">                     <span class="type">int</span> whichWallpaper)</span> <span class="keyword">throws</span> IOException &#123;</span><br><span class="line">    mWallpaperManager.setStream(data);</span><br><span class="line">    <span class="comment">// Return a value greater than zero to indicate success.</span></span><br><span class="line">    <span class="keyword">return</span> <span class="number">1</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>由此可知，壁纸的设置是通过 WallpaperManager 类来进行的。</p>
<h3 id="二、锁屏壁纸的显示"><a href="#二、锁屏壁纸的显示" class="headerlink" title="二、锁屏壁纸的显示"></a>二、锁屏壁纸的显示</h3><p>锁屏壁纸显示流程图：</p>
<p><img src="/images/20240101/20240101001.png"></p>
<p>上面应用程序设置完成了，下面就该进行壁纸显示了。<br>WallpaperManager#setStream()<br><strong>frameworks/base/core/java/android/app/WallpaperManager.java</strong></p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="type">int</span> <span class="title function_">setStream</span><span class="params">(InputStream bitmapData, Rect visibleCropHint,</span></span><br><span class="line"><span class="params">        <span class="type">boolean</span> allowBackup, <span class="meta">@SetWallpaperFlags</span> <span class="type">int</span> which)</span></span><br><span class="line">                <span class="keyword">throws</span> IOException &#123;</span><br><span class="line">    <span class="comment">// 省略部分代码......</span></span><br><span class="line">    <span class="keyword">try</span> &#123;</span><br><span class="line">        <span class="comment">//sGlobals.mService即 WallpaperManagerService。</span></span><br><span class="line">        <span class="comment">// WallpaperManager 在 SystemServiceRegistry 实例化，</span></span><br><span class="line">        <span class="comment">// 过程中传入 WallpaperManagerService 的 binder 对象。   </span></span><br><span class="line">        <span class="type">ParcelFileDescriptor</span> <span class="variable">fd</span> <span class="operator">=</span> sGlobals.mService.setWallpaper(<span class="literal">null</span>,</span><br><span class="line">                mContext.getOpPackageName(), visibleCropHint, allowBackup,</span><br><span class="line">                result, which, completion, mContext.getUserId());</span><br><span class="line">        <span class="keyword">if</span> (fd != <span class="literal">null</span>) &#123;</span><br><span class="line">            <span class="type">FileOutputStream</span> <span class="variable">fos</span> <span class="operator">=</span> <span class="literal">null</span>;</span><br><span class="line">            <span class="keyword">try</span> &#123;</span><br><span class="line">                <span class="comment">// 将壁纸copy一份并存储到对应目录，</span></span><br><span class="line">                <span class="comment">// 默认是/data/system/users/0/wallpaper(或wallpaper_lock),</span></span><br><span class="line">                <span class="comment">// 其中0是主用户的userId，支持多用户</span></span><br><span class="line">                fos = <span class="keyword">new</span> <span class="title class_">ParcelFileDescriptor</span>.AutoCloseOutputStream(fd);</span><br><span class="line">                copyStreamToWallpaperFile(bitmapData, fos);</span><br><span class="line">                fos.close();</span><br><span class="line">                completion.waitForCompletion();</span><br><span class="line">            &#125; <span class="keyword">finally</span> &#123;</span><br><span class="line">                IoUtils.closeQuietly(fos);</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125; <span class="keyword">catch</span> (RemoteException e) &#123;</span><br><span class="line">        <span class="keyword">throw</span> e.rethrowFromSystemServer();</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> result.getInt(EXTRA_NEW_WALLPAPER_ID, <span class="number">0</span>);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<blockquote>
<p>这里注意两个方法：sGlobals.mService.setWallpaper()和fos.close()。</p>
</blockquote>
<p>先看第一个 <strong>WallpaperManagerService#setWallpaper()</strong> 方法：<br><strong>frameworks/base/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java</strong></p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> ParcelFileDescriptor <span class="title function_">setWallpaper</span><span class="params">(String name, String callingPackage,</span></span><br><span class="line"><span class="params">        Rect cropHint, <span class="type">boolean</span> allowBackup, Bundle extras, <span class="type">int</span> which,</span></span><br><span class="line"><span class="params">        IWallpaperManagerCallback completion, <span class="type">int</span> userId)</span> &#123;</span><br><span class="line">    userId = ActivityManager.handleIncomingUser(getCallingPid(), getCallingUid(), userId,</span><br><span class="line">            <span class="literal">false</span> <span class="comment">/* all */</span>, <span class="literal">true</span> <span class="comment">/* full */</span>, <span class="string">&quot;changing wallpaper&quot;</span>, <span class="literal">null</span> <span class="comment">/* pkg */</span>);</span><br><span class="line">    <span class="comment">// 检查有没有设置壁纸的权限</span></span><br><span class="line">   checkPermission(android.Manifest.permission.SET_WALLPAPER);</span><br><span class="line">    </span><br><span class="line">     <span class="comment">//调用setStream方法的时候参数which必须是正确的</span></span><br><span class="line">    <span class="keyword">if</span> ((which &amp; (FLAG_LOCK|FLAG_SYSTEM)) == <span class="number">0</span>) &#123;</span><br><span class="line">        <span class="keyword">final</span> <span class="type">String</span> <span class="variable">msg</span> <span class="operator">=</span> <span class="string">&quot;Must specify a valid wallpaper category to set&quot;</span>;</span><br><span class="line">        Slog.e(TAG, msg);</span><br><span class="line">        <span class="keyword">throw</span> <span class="keyword">new</span> <span class="title class_">IllegalArgumentException</span>(msg);</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="comment">// 省略部分代码......</span></span><br><span class="line">    <span class="keyword">synchronized</span> (mLock) &#123;</span><br><span class="line">        <span class="keyword">if</span> (DEBUG) Slog.v(TAG, <span class="string">&quot;setWallpaper which=0x&quot;</span> + Integer.toHexString(which));</span><br><span class="line">        WallpaperData wallpaper;</span><br><span class="line">  </span><br><span class="line">        <span class="comment">//如果当前没有锁屏壁纸的话，并且是设置桌面壁纸即which == FLAG_SYSTEM，那么同时设置为锁屏壁纸</span></span><br><span class="line">        <span class="keyword">if</span> (which == FLAG_SYSTEM &amp;&amp; mLockWallpaperMap.get(userId) == <span class="literal">null</span>) &#123;</span><br><span class="line">            migrateSystemToLockWallpaperLocked(userId);</span><br><span class="line">        &#125;</span><br><span class="line">        wallpaper = getWallpaperSafeLocked(userId, which);</span><br><span class="line">        <span class="keyword">final</span> <span class="type">long</span> <span class="variable">ident</span> <span class="operator">=</span> Binder.clearCallingIdentity();</span><br><span class="line">        <span class="keyword">try</span> &#123;</span><br><span class="line">            <span class="comment">// updateWallpaperBitmapLocked() 将创建一个文件描述符</span></span><br><span class="line">            <span class="type">ParcelFileDescriptor</span> <span class="variable">pfd</span> <span class="operator">=</span> updateWallpaperBitmapLocked(name, wallpaper, extras);</span><br><span class="line">            <span class="keyword">if</span> (pfd != <span class="literal">null</span>) &#123;</span><br><span class="line">                wallpaper.imageWallpaperPending = <span class="literal">true</span>;</span><br><span class="line">                wallpaper.whichPending = which;</span><br><span class="line">                wallpaper.setComplete = completion;</span><br><span class="line">                wallpaper.cropHint.set(cropHint);</span><br><span class="line">                wallpaper.allowBackup = allowBackup;</span><br><span class="line">            &#125;</span><br><span class="line">            <span class="keyword">return</span> pfd;</span><br><span class="line">        &#125; <span class="keyword">finally</span> &#123;</span><br><span class="line">            Binder.restoreCallingIdentity(ident);</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>这里再跟进一步，看下 <strong>updateWallpaperBitmapLocked()</strong> 方法：<br><strong>frameworks/base/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java</strong></p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line">ParcelFileDescriptor <span class="title function_">updateWallpaperBitmapLocked</span><span class="params">(String name, WallpaperData wallpaper,</span></span><br><span class="line"><span class="params">        Bundle extras)</span> &#123;</span><br><span class="line">    <span class="keyword">if</span> (name == <span class="literal">null</span>) name = <span class="string">&quot;&quot;</span>;</span><br><span class="line">    <span class="keyword">try</span> &#123;</span><br><span class="line">        <span class="comment">// 通过getWallpaperDir() 获取文件路径；这个方法值得注意：后面会讲到。</span></span><br><span class="line">        <span class="type">File</span> <span class="variable">dir</span> <span class="operator">=</span> getWallpaperDir(wallpaper.userId);</span><br><span class="line">        <span class="keyword">if</span> (!dir.exists()) &#123;</span><br><span class="line">            dir.mkdir();</span><br><span class="line">            FileUtils.setPermissions(</span><br><span class="line">                    dir.getPath(),</span><br><span class="line">                    FileUtils.S_IRWXU|FileUtils.S_IRWXG|FileUtils.S_IXOTH,</span><br><span class="line">                    -<span class="number">1</span>, -<span class="number">1</span>);</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="comment">// 创建一个文件描述符，并返回。</span></span><br><span class="line">        <span class="type">ParcelFileDescriptor</span> <span class="variable">fd</span> <span class="operator">=</span> ParcelFileDescriptor.open(wallpaper.wallpaperFile,</span><br><span class="line">                MODE_CREATE|MODE_READ_WRITE|MODE_TRUNCATE);</span><br><span class="line">        <span class="comment">// 省略部分代码......</span></span><br><span class="line">        <span class="keyword">return</span> fd;</span><br><span class="line">    &#125; <span class="keyword">catch</span> (FileNotFoundException e) &#123;</span><br><span class="line">        Slog.w(TAG, <span class="string">&quot;Error setting wallpaper&quot;</span>, e);</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> <span class="literal">null</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>这里再看 <strong>fos.close()</strong> ，这个方法本身没什么可以看的，就是 FileOutputStream  文件字节输出流结束。但是这里涉及到了 WallpaperManagerService 的一个内部类 WallpaperObserver，通过名字我们就能知道它是一个观察者。<br><strong>WallpaperObserver 初始化</strong>：在 WallpaperManagerService 初始化时，会调用 systemReady() 通过getWallpaperSafeLocked()方法初始化 WallpaperData，而这个 WallpaperData 中有个变量 wallpaperObserver ，也在开机时服务初始化， systemReady() 中调用 switchUser() 执行了 wallpaperObserver.startWatching()。<br><strong>WallpaperObserver 这个内部类的作用</strong>：观察壁纸的变化并通知所有 IWallpaperServiceCallbacks 壁纸已经改变。 CREATE 在没有设置壁纸时触发，并且是第一次创建。每次更改壁纸时都会触发 CLOSE_WRITE，这也是关注 <strong>fos.close()</strong> 的原因。<br>所以文件的变化触发 WallpaperObserver 的 onEvent() ：<br><strong>frameworks/base/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java</strong></p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">@Override</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title function_">onEvent</span><span class="params">(<span class="type">int</span> event, String path)</span> &#123;</span><br><span class="line">    <span class="keyword">if</span> (path == <span class="literal">null</span>) &#123;</span><br><span class="line">        <span class="keyword">return</span>;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">final</span> <span class="type">boolean</span> <span class="variable">moved</span> <span class="operator">=</span> (event == MOVED_TO);</span><br><span class="line">    <span class="keyword">final</span> <span class="type">boolean</span> <span class="variable">written</span> <span class="operator">=</span> (event == CLOSE_WRITE || moved);</span><br><span class="line">    <span class="comment">// 获取发生了 CLOSE_WRITE 事件的文件路径</span></span><br><span class="line">    <span class="keyword">final</span> <span class="type">File</span> <span class="variable">changedFile</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">File</span>(mWallpaperDir, path);</span><br><span class="line">    <span class="comment">// System and system+lock changes happen on the system wallpaper input file;</span></span><br><span class="line">    <span class="comment">// lock-only changes happen on the dedicated lock wallpaper input file</span></span><br><span class="line">    <span class="comment">// 用于判断事件是不是这个事件发生的。</span></span><br><span class="line">    <span class="keyword">final</span> <span class="type">boolean</span> <span class="variable">sysWallpaperChanged</span> <span class="operator">=</span> (mWallpaperFile.equals(changedFile));</span><br><span class="line">    <span class="keyword">final</span> <span class="type">boolean</span> <span class="variable">lockWallpaperChanged</span> <span class="operator">=</span> (mWallpaperLockFile.equals(changedFile));</span><br><span class="line">    <span class="type">int</span> <span class="variable">notifyColorsWhich</span> <span class="operator">=</span> <span class="number">0</span>;</span><br><span class="line">    <span class="type">WallpaperData</span> <span class="variable">wallpaper</span> <span class="operator">=</span> dataForEvent(sysWallpaperChanged, lockWallpaperChanged);</span><br><span class="line">    <span class="comment">// 如果是锁屏壁纸更新</span></span><br><span class="line">    <span class="keyword">if</span> (moved &amp;&amp; lockWallpaperChanged) &#123;</span><br><span class="line">        SELinux.restorecon(changedFile);</span><br><span class="line">        notifyLockWallpaperChanged();</span><br><span class="line">        notifyWallpaperColorsChanged(wallpaper, FLAG_LOCK);</span><br><span class="line">        <span class="keyword">return</span>;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">synchronized</span> (mLock) &#123;</span><br><span class="line">        <span class="keyword">if</span> (sysWallpaperChanged || lockWallpaperChanged) &#123;</span><br><span class="line">            notifyCallbacksLocked(wallpaper);</span><br><span class="line">            <span class="keyword">if</span> (wallpaper.wallpaperComponent == <span class="literal">null</span></span><br><span class="line">                    || event != CLOSE_WRITE <span class="comment">// includes the MOVED_TO case</span></span><br><span class="line">                    || wallpaper.imageWallpaperPending) &#123;</span><br><span class="line">                <span class="keyword">if</span> (written) &#123;</span><br><span class="line">          </span><br><span class="line">                    SELinux.restorecon(changedFile);</span><br><span class="line">                    <span class="keyword">if</span> (moved) &#123;</span><br><span class="line">                        loadSettingsLocked(wallpaper.userId, <span class="literal">true</span>);</span><br><span class="line">                    &#125;</span><br><span class="line">                    generateCrop(wallpaper);</span><br><span class="line">                  </span><br><span class="line">                    wallpaper.imageWallpaperPending = <span class="literal">false</span>;</span><br><span class="line">                    <span class="keyword">if</span> (sysWallpaperChanged) &#123;</span><br><span class="line">                        <span class="comment">// 桌面壁纸变化，那么bind ImageWallpaper，ImageWallpaper是负责显示静态桌面壁纸的</span></span><br><span class="line">                       bindWallpaperComponentLocked(mImageWallpaper, <span class="literal">true</span>,</span><br><span class="line">                                <span class="literal">false</span>, wallpaper, <span class="literal">null</span>);</span><br><span class="line">                        notifyColorsWhich |= FLAG_SYSTEM;</span><br><span class="line">                    &#125;</span><br><span class="line">                    <span class="keyword">if</span> (lockWallpaperChanged</span><br><span class="line">                            || (wallpaper.whichPending &amp; FLAG_LOCK) != <span class="number">0</span>) &#123;</span><br><span class="line">                        <span class="keyword">if</span> (DEBUG) &#123;</span><br><span class="line">                            Slog.i(TAG, <span class="string">&quot;Lock-relevant wallpaper changed&quot;</span>);</span><br><span class="line">                        &#125;</span><br><span class="line">                    </span><br><span class="line">                        <span class="keyword">if</span> (!lockWallpaperChanged) &#123;</span><br><span class="line">                            <span class="comment">//如果参数which是system+lock，也就是同时设置锁屏和桌面壁纸，那么remove锁屏壁纸，因为已经是同一张壁纸了</span></span><br><span class="line">                            mLockWallpaperMap.remove(wallpaper.userId);</span><br><span class="line">                        &#125;</span><br><span class="line">                        <span class="comment">// and in any case, tell keyguard about it</span></span><br><span class="line">                        notifyLockWallpaperChanged();</span><br><span class="line">                        notifyColorsWhich |= FLAG_LOCK;</span><br><span class="line">                    &#125;</span><br><span class="line">                    saveSettingsLocked(wallpaper.userId);</span><br><span class="line">                    <span class="comment">// Publish completion *after* we&#x27;ve persisted the changes</span></span><br><span class="line">                    <span class="keyword">if</span> (wallpaper.setComplete != <span class="literal">null</span>) &#123;</span><br><span class="line">                        <span class="keyword">try</span> &#123;</span><br><span class="line">                            wallpaper.setComplete.onWallpaperChanged();</span><br><span class="line">                        &#125; <span class="keyword">catch</span> (RemoteException e) &#123;</span><br><span class="line">                            <span class="comment">// if this fails we don&#x27;t really care; the setting app may just</span></span><br><span class="line">                            <span class="comment">// have crashed and that sort of thing is a fact of life.</span></span><br><span class="line">                        &#125;</span><br><span class="line">                    &#125;</span><br><span class="line">                &#125;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="comment">// Outside of the lock since it will synchronize itself</span></span><br><span class="line">    <span class="keyword">if</span> (notifyColorsWhich != <span class="number">0</span>) &#123;</span><br><span class="line">        notifyWallpaperColorsChanged(wallpaper, notifyColorsWhich);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>先看锁屏壁纸更新这一部分 <strong>notifyLockWallpaperChanged()</strong> ：<br><strong>frameworks/base/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java</strong></p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">private</span> <span class="keyword">void</span> <span class="title function_">notifyLockWallpaperChanged</span><span class="params">()</span> &#123;</span><br><span class="line">    <span class="keyword">final</span> <span class="type">IWallpaperManagerCallback</span> <span class="variable">cb</span> <span class="operator">=</span> mKeyguardListener;</span><br><span class="line">    <span class="keyword">if</span> (cb != <span class="literal">null</span>) &#123;</span><br><span class="line">        <span class="keyword">try</span> &#123;</span><br><span class="line">            cb.onWallpaperChanged();</span><br><span class="line">        &#125; <span class="keyword">catch</span> (RemoteException e) &#123;</span><br><span class="line">            <span class="comment">// Oh well it went away; no big deal</span></span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"><span class="meta">@Override</span></span><br><span class="line"><span class="keyword">public</span> <span class="type">boolean</span> <span class="title function_">setLockWallpaperCallback</span><span class="params">(IWallpaperManagerCallback cb)</span> &#123;</span><br><span class="line">    checkPermission(android.Manifest.permission.INTERNAL_SYSTEM_WINDOW);</span><br><span class="line">    <span class="keyword">synchronized</span> (mLock) &#123;</span><br><span class="line">        mKeyguardListener = cb;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> <span class="literal">true</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>notifyLockWallpaperChanged 中执行 cb.onWallpaperChanged()；这里的 cb = mKeyguardListener，而 mKeyguardListener 在 setLockWallpaperCallback() 方法中得到。 跟进我们发现 cb 其实就是 LockscreenWallpaper 引用，在 <strong>LockscreenWallpaper</strong>  的构造方法里赋值调用：<br><strong>frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/LockscreenWallpaper.java</strong></p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">@Inject</span></span><br><span class="line"><span class="keyword">public</span> <span class="title function_">LockscreenWallpaper</span><span class="params">(WallpaperManager wallpaperManager,</span></span><br><span class="line"><span class="params">        <span class="meta">@Nullable</span> IWallpaperManager iWallpaperManager,</span></span><br><span class="line"><span class="params">        KeyguardUpdateMonitor keyguardUpdateMonitor,</span></span><br><span class="line"><span class="params">        DumpManager dumpManager,</span></span><br><span class="line"><span class="params">        NotificationMediaManager mediaManager,</span></span><br><span class="line"><span class="params">        <span class="meta">@Main</span> Handler mainHandler)</span> &#123;</span><br><span class="line">    <span class="comment">// 省略部分代码......</span></span><br><span class="line">    <span class="keyword">if</span> (iWallpaperManager != <span class="literal">null</span>) &#123;</span><br><span class="line">        <span class="comment">// Service is disabled on some devices like Automotive</span></span><br><span class="line">        <span class="keyword">try</span> &#123;</span><br><span class="line">            <span class="comment">// iWallpaperManager 是 WallpaperManagerService 的 binder对象，</span></span><br><span class="line">            <span class="comment">// 通过 dagger 在 SystemServicesModule 实例化。</span></span><br><span class="line">            iWallpaperManager.setLockWallpaperCallback(<span class="built_in">this</span>);</span><br><span class="line">        &#125; <span class="keyword">catch</span> (RemoteException e) &#123;</span><br><span class="line">            Log.e(TAG, <span class="string">&quot;System dead?&quot;</span> + e);</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>所以当锁屏壁纸更新时，就会回调到 <strong>LockscreenWallpaper#onWallpaperChanged()</strong> ：<br><strong>frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/LockscreenWallpaper.java</strong></p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">@Override</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title function_">onWallpaperChanged</span><span class="params">()</span> &#123;</span><br><span class="line">    <span class="comment">// Called on Binder thread.</span></span><br><span class="line">    postUpdateWallpaper();</span><br><span class="line">&#125;</span><br><span class="line"><span class="keyword">private</span> <span class="keyword">void</span> <span class="title function_">postUpdateWallpaper</span><span class="params">()</span> &#123;</span><br><span class="line">    <span class="keyword">if</span> (mH == <span class="literal">null</span>) &#123;</span><br><span class="line">        Log.wtfStack(TAG, <span class="string">&quot;Trying to use LockscreenWallpaper before initialization.&quot;</span>);</span><br><span class="line">        <span class="keyword">return</span>;</span><br><span class="line">    &#125;</span><br><span class="line">    mH.removeCallbacks(<span class="built_in">this</span>);</span><br><span class="line">    mH.post(<span class="built_in">this</span>);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>而 LockscreenWallpaper 类实现了 Runnable 接口的，所以看下它的 run() 方法； <strong>LockscreenWallpaper#run()</strong> ：<br><strong>frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/LockscreenWallpaper.java</strong></p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">@Override</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title function_">run</span><span class="params">()</span> &#123;</span><br><span class="line">    <span class="comment">// Called in response to onWallpaperChanged on the main thread.</span></span><br><span class="line">    <span class="keyword">if</span> (mLoader != <span class="literal">null</span>) &#123;</span><br><span class="line">        mLoader.cancel(<span class="literal">false</span> <span class="comment">/* interrupt */</span>);</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">final</span> <span class="type">int</span> <span class="variable">currentUser</span> <span class="operator">=</span> mCurrentUserId;</span><br><span class="line">    <span class="keyword">final</span> <span class="type">UserHandle</span> <span class="variable">selectedUser</span> <span class="operator">=</span> mSelectedUser;</span><br><span class="line">    mLoader = <span class="keyword">new</span> <span class="title class_">AsyncTask</span>&lt;Void, Void, LoaderResult&gt;() &#123;</span><br><span class="line">        <span class="meta">@Override</span></span><br><span class="line">        <span class="keyword">protected</span> LoaderResult <span class="title function_">doInBackground</span><span class="params">(Void... params)</span> &#123;</span><br><span class="line">            <span class="keyword">return</span> loadBitmap(currentUser, selectedUser);</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="meta">@Override</span></span><br><span class="line">        <span class="keyword">protected</span> <span class="keyword">void</span> <span class="title function_">onPostExecute</span><span class="params">(LoaderResult result)</span> &#123;</span><br><span class="line">            <span class="built_in">super</span>.onPostExecute(result);</span><br><span class="line">            <span class="keyword">if</span> (isCancelled()) &#123;</span><br><span class="line">                <span class="keyword">return</span>;</span><br><span class="line">            &#125;</span><br><span class="line">            <span class="keyword">if</span> (result.success) &#123;</span><br><span class="line">                mCached = <span class="literal">true</span>;</span><br><span class="line">                mCache = result.bitmap;</span><br><span class="line">                mUpdateMonitor.setHasLockscreenWallpaper(result.bitmap != <span class="literal">null</span>);</span><br><span class="line">                <span class="comment">// 通知StatusBar更新壁纸</span></span><br><span class="line">                mMediaManager.updateMediaMetaData(</span><br><span class="line">                        <span class="literal">true</span> <span class="comment">/* metaDataChanged */</span>, <span class="literal">true</span> <span class="comment">/* allowEnterAnimation */</span>);</span><br><span class="line">            &#125;</span><br><span class="line">            mLoader = <span class="literal">null</span>;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>异步获取壁纸，并通知StatusBar去更新壁纸。<br><strong>NotificationMediaManager#updateMediaMetaData()</strong><br><strong>frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/NotificationMediaManager.java</strong></p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title function_">updateMediaMetaData</span><span class="params">(<span class="type">boolean</span> metaDataChanged, <span class="type">boolean</span> allowEnterAnimation)</span> &#123;</span><br><span class="line">    Trace.beginSection(<span class="string">&quot;StatusBar#updateMediaMetaData&quot;</span>);</span><br><span class="line">  </span><br><span class="line">    <span class="comment">// 省略部分代码......</span></span><br><span class="line">    <span class="type">Bitmap</span> <span class="variable">artworkBitmap</span> <span class="operator">=</span> <span class="literal">null</span>;</span><br><span class="line">    <span class="keyword">if</span> (mediaMetadata != <span class="literal">null</span> &amp;&amp; !mKeyguardBypassController.getBypassEnabled()) &#123;</span><br><span class="line">        artworkBitmap = mediaMetadata.getBitmap(MediaMetadata.METADATA_KEY_ART);</span><br><span class="line">        <span class="keyword">if</span> (artworkBitmap == <span class="literal">null</span>) &#123;</span><br><span class="line">            artworkBitmap = mediaMetadata.getBitmap(MediaMetadata.METADATA_KEY_ALBUM_ART);</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line"> </span><br><span class="line">    <span class="comment">//在后台线程上处理图稿并将生成的位图发送到finishUpdateMediaMetaData。</span></span><br><span class="line">    <span class="keyword">if</span> (metaDataChanged) &#123;</span><br><span class="line">        <span class="keyword">for</span> (AsyncTask&lt;?, ?, ?&gt; task : mProcessArtworkTasks) &#123;</span><br><span class="line">            task.cancel(<span class="literal">true</span>);</span><br><span class="line">        &#125;</span><br><span class="line">        mProcessArtworkTasks.clear();</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">if</span> (artworkBitmap != <span class="literal">null</span> &amp;&amp; !Utils.useQsMediaPlayer(mContext)) &#123;</span><br><span class="line">        mProcessArtworkTasks.add(<span class="keyword">new</span> <span class="title class_">ProcessArtworkTask</span>(<span class="built_in">this</span>, metaDataChanged,</span><br><span class="line">                allowEnterAnimation).execute(artworkBitmap));</span><br><span class="line">    &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">        finishUpdateMediaMetaData(metaDataChanged, allowEnterAnimation, <span class="literal">null</span>);</span><br><span class="line">    &#125;</span><br><span class="line">    Trace.endSection();</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>对锁屏壁纸所在 view 做 setImageBitmap。<br><strong>frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/NotificationMediaManager.java</strong></p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">private</span> <span class="keyword">void</span> <span class="title function_">finishUpdateMediaMetaData</span><span class="params">(<span class="type">boolean</span> metaDataChanged, <span class="type">boolean</span> allowEnterAnimation,</span></span><br><span class="line"><span class="params">        <span class="meta">@Nullable</span> Bitmap bmp)</span> &#123;</span><br><span class="line">    <span class="type">Drawable</span> <span class="variable">artworkDrawable</span> <span class="operator">=</span> <span class="literal">null</span>;</span><br><span class="line">    <span class="keyword">if</span> (bmp != <span class="literal">null</span>) &#123;</span><br><span class="line">        artworkDrawable = <span class="keyword">new</span> <span class="title class_">BitmapDrawable</span>(mBackdropBack.getResources(), bmp);</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="comment">// 省略部分代码......</span></span><br><span class="line">    <span class="keyword">if</span> ((hasArtwork || DEBUG_MEDIA_FAKE_ARTWORK)</span><br><span class="line">            &amp;&amp; (mStatusBarStateController.getState() != StatusBarState.SHADE || allowWhenShade)</span><br><span class="line">            &amp;&amp;  mBiometricUnlockController != <span class="literal">null</span> &amp;&amp; mBiometricUnlockController.getMode()</span><br><span class="line">                    != BiometricUnlockController.MODE_WAKE_AND_UNLOCK_PULSING</span><br><span class="line">            &amp;&amp; !hideBecauseOccluded) &#123;</span><br><span class="line">         <span class="comment">// 省略部分代码......</span></span><br><span class="line">        <span class="keyword">if</span> (metaDataChanged) &#123;</span><br><span class="line">            <span class="keyword">if</span> (mBackdropBack.getDrawable() != <span class="literal">null</span>) &#123;</span><br><span class="line">                <span class="type">Drawable</span> <span class="variable">drawable</span> <span class="operator">=</span></span><br><span class="line">                        mBackdropBack.getDrawable().getConstantState()</span><br><span class="line">                                .newDrawable(mBackdropFront.getResources()).mutate();</span><br><span class="line">                <span class="comment">// 设置壁纸 setImageDrawable()</span></span><br><span class="line">                mBackdropFront.setImageDrawable(drawable);</span><br><span class="line">                mBackdropFront.setAlpha(<span class="number">1f</span>);</span><br><span class="line">                mBackdropFront.setVisibility(View.VISIBLE);</span><br><span class="line">            &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">                mBackdropFront.setVisibility(View.INVISIBLE);</span><br><span class="line">            &#125;</span><br><span class="line"> </span><br><span class="line">            <span class="keyword">if</span> (DEBUG_MEDIA_FAKE_ARTWORK) &#123;</span><br><span class="line">                <span class="keyword">final</span> <span class="type">int</span> <span class="variable">c</span> <span class="operator">=</span> <span class="number">0xFF000000</span> | (<span class="type">int</span>)(Math.random() * <span class="number">0xFFFFFF</span>);</span><br><span class="line">                Log.v(TAG, String.format(<span class="string">&quot;DEBUG_MEDIA: setting new color: 0x%08x&quot;</span>, c));</span><br><span class="line">                mBackdropBack.setBackgroundColor(<span class="number">0xFFFFFFFF</span>);</span><br><span class="line">                mBackdropBack.setImageDrawable(<span class="keyword">new</span> <span class="title class_">ColorDrawable</span>(c));</span><br><span class="line">            &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">                mBackdropBack.setImageDrawable(artworkDrawable);</span><br><span class="line">            &#125;</span><br><span class="line"> </span><br><span class="line">            <span class="keyword">if</span> (mBackdropFront.getVisibility() == View.VISIBLE) &#123;</span><br><span class="line">                <span class="keyword">if</span> (DEBUG_MEDIA) &#123;</span><br><span class="line">                    Log.v(TAG, <span class="string">&quot;DEBUG_MEDIA: Crossfading album artwork from &quot;</span></span><br><span class="line">                            + mBackdropFront.getDrawable()</span><br><span class="line">                            + <span class="string">&quot; to &quot;</span></span><br><span class="line">                            + mBackdropBack.getDrawable());</span><br><span class="line">                &#125;</span><br><span class="line">                mBackdropFront.animate()</span><br><span class="line">                        .setDuration(<span class="number">250</span>)</span><br><span class="line">                        .alpha(<span class="number">0f</span>).withEndAction(mHideBackdropFront);</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">        <span class="comment">// 省略部分代码......</span></span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>通过 mBackdropFront.setImageDrawable(drawable) 方法将图片设置进去，完成锁屏壁纸的更新。<br>mBackdropFront 在 NotificationMediaManager的 <strong>setup()</strong> 方法被赋值，而 setup() 方法在 StatusBar 的 makeStatusBarView() 中被调用初始化。<br><strong>StatusBar#makeStatusBarView()</strong><br><strong>frameworks/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/StatusBar.java</strong></p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">protected</span> <span class="keyword">void</span> <span class="title function_">makeStatusBarView</span><span class="params">(<span class="meta">@Nullable</span> RegisterStatusBarResult result)</span> &#123;</span><br><span class="line">    <span class="comment">// 省略部分代码......</span></span><br><span class="line">    mMediaManager.setup(backdrop, backdrop.findViewById(R.id.backdrop_front),</span><br><span class="line">            backdrop.findViewById(R.id.backdrop_back), mScrimController, mLockscreenWallpaper);</span><br><span class="line">    <span class="comment">// 省略部分代码......</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>


      
      <blockquote>
        
        <strong>本文链接：</strong><br><a href="http://longzhiye.top/2024/01/01/2024-01-01/">http://longzhiye.top/2024/01/01/2024-01-01/</a>
      </blockquote>
    </div>
    <footer class="mdui-card-actions">
      
        <a class="mdui-ripple article_categories-link" href="/categories/%E6%8A%80%E6%9C%AF/">技术</a>
      
      
        <a class="mdui-ripple article_tags-link" href="/tags/Android/" rel="tag">Android</a><a class="mdui-ripple article_tags-link" href="/tags/Launcher/" rel="tag">Launcher</a><a class="mdui-ripple article_tags-link" href="/tags/Settings/" rel="tag">Settings</a><a class="mdui-ripple article_tags-link" href="/tags/framework/" rel="tag">framework</a>
      
    </footer>
    
  </article>
  
<script src="//cdn.bootcdn.net/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="//cdn.bootcdn.net/ajax/libs/fancybox/3.5.7/jquery.fancybox.min.js"></script>

  <script>$("#main article .mdui-card-content img.fancybox").on("click",function(e){$.fancybox.open({src:$(this).attr("src")});});</script>


  <nav id="paginator">
    
      <a rel="prev" class="extend prev" href="/2024/01/06/2024-01-06/">
        <button aria-label="prev" class="mdui-btn mdui-btn-raised mdui-btn-icon mdui-color-theme-accent mdui-ripple"><i class="mdui-icon material-icons">arrow_back</i></button>
        <span class="mdui-p-x-3" mdui-tooltip="{content: 'Android 10 Android音量调节'}">上一篇</span>
      </a>
    
    <div class="spacer"></div>
    
      <a rel="next" class="extend next" href="/2023/12/31/2023-12-31/">
        <span class="mdui-p-x-3" mdui-tooltip="{content: 'Android 10.0 动态壁纸 LiveWallpaper'}">下一篇</span>
        <button aria-label="next" class="mdui-btn mdui-btn-raised mdui-btn-icon mdui-color-theme-accent mdui-ripple"><i class="mdui-icon material-icons">arrow_forward</i></button>
      </a>
    
  </nav>





</main>
  <footer id="footer" class="mdui-m-t-5 mdui-p-y-3 mdui-color-theme">
  <div class="mdui-p-y-0 mdui-text-center">
    
    
    
    
    
    
    
      <a href="http://github.com/longzhiye" target="_blank" class="mdui-btn mdui-btn-icon mdui-text-color-theme-a100"><i class="mdui-icon iconfont">&#xe7ab;</i></a>
    
    
    
      <a href="https://www.zhihu.com/people/long-zhi-xie-61" target="_blank" class="mdui-btn mdui-btn-icon mdui-text-color-theme-a100"><i class="mdui-icon iconfont">&#xe6c0;</i></a>
    
    
    
      <a href="tencent://tencent:////message/?uin=951898105&Menu=yes" target="_blank" class="mdui-btn mdui-btn-icon mdui-text-color-theme-a100"><i class="mdui-icon iconfont">&#xe651;</i></a>
    
    
  </div>
  <div class="mdui-p-y-1 mdui-text-center">
    Copyright &copy; 2022 - 2025 龙之叶<br>
    Powered by <a href="https://hexo.io/" target="_blank" class="mdui-text-color-theme-accent">Hexo</a>
    <br>
      <span id="busuanzi_container_site_pv" style="display: none;"><i class="iconfont">&#xe7fd;</i> <span id="busuanzi_value_site_pv"></span></span> &nbsp;&nbsp;
      <span id="busuanzi_container_site_uv" style="display: none;"><i class="iconfont">&#xe601;</i> <span id="busuanzi_value_site_uv"></span></span>
    
  </div>
</footer>

  <button id="gotop" class="mdui-fab mdui-fab-fixed mdui-fab-hide mdui-color-theme-accent mdui-ripple"><i class="mdui-icon material-icons">arrow_upward</i></button>
  <script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
  
<script src="/js/mdui.js"></script>
<script src="/js/script.js"></script>

  
<script src="/custom.js"></script>

</body>
</html>
